package com.cass.controller;

import com.cass.entity.SocialPractice;
import com.cass.entity.Vo.studentVo;
import com.cass.service.SocialPracticeService;
import com.cass.uilts.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/socialPractice")
@RequiredArgsConstructor
public class SocialPracticeController {
    private static final Logger logger = LoggerFactory.getLogger(StudentController.class);
    private final SocialPracticeService socialPracticeService;
    @GetMapping
    public Result<List<SocialPractice>> getSocialPractice(){
        logger.info("获得社会实践");
        List<SocialPractice> SocialPractice = socialPracticeService.list();
        return Result.success(SocialPractice);
    }
    @PostMapping
    public Result<String> addSocialPractice(@RequestBody SocialPractice socialPractice){
        logger.info("添加社会实践");
        socialPracticeService.save(socialPractice);
        return Result.success("添加成功");
    }
    @DeleteMapping("/{id}")
    public Result<String> deleteSocialPractice(@PathVariable Integer id){
        logger.info("删除社会实践");
        socialPracticeService.removeById(id);
        return Result.success("删除成功");
    }
    @PutMapping
    public Result<String> updateSocialPractice(@RequestBody SocialPractice socialPractice){
        logger.info("修改社会实践");
        socialPracticeService.updateById(socialPractice);
        return Result.success("修改成功");
    }
    @DeleteMapping("/batchDelete")
    public Result<String> batchDelete(@RequestBody List<Integer> ids){
        logger.info("批量删除社会实践");
        socialPracticeService.removeByIds(ids);
        return Result.success("批量删除成功");
    }
}
